<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<form id="form_extra" action="<?php echo url_for('extra/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id_item='.$form->getObject()->getIdItem() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<input type="hidden" name="id_item" value="<?php echo $form->getObject()->getIdItem() ?>" />
<?php endif; ?>
<?php echo $form->renderHiddenFields() ?>
<input type="hidden" name="item[id_tipo]" value="<?php echo Tipo::PAGINAS; ?>" />

<div class="tabs">
    <ul>
        <li><a href="#tab_dados">Dados</a></li>
        <?php if (!$form->getObject()->isNew()): ?>
            <li><a href="<?php echo url_for('midia/arquivos?ref_name=id_item&ref_value='.$form->getObject()->getIdItem().'&hasmany=true'); ?>">Arquivo(s)</a></li>
        <?php else: ?>
            <li><a href="#tab_midia">Imagens(s)</a></li>
        <?php endif; ?>
    </ul>
    
    <div id="tab_dados">
		  <table class="form">
		    <tbody>
		      <tr><th colspan="2" class="title">Dados conteudo</th></tr>
		      <?php echo $form->renderGlobalErrors() ?>
		      <tr>
		        <th class="required"><?php echo $form['nm_item']->renderLabel() ?></th>
		        <td>
		          <?php echo $form['nm_item'] ?>
		          <?php echo form_error('item[nm_item]'); ?>
		        </td>
		      </tr>
		      <tr>
		        <th><?php echo $form['st_item']->renderLabel() ?></th>
		        <td>
		          <?php echo $form['st_item'] ?>
		          <?php echo form_error('item[st_item]'); ?>
		        </td>
		      </tr>
		      <tr>
		        <th class="required"><?php echo $form['ds_item']->renderLabel() ?></th>
		        <td>
		          <?php echo $form['ds_item'] ?>
		          <?php echo form_error('item[ds_item]'); ?>
		        </td>
		      </tr>
		      <tr>
		        <th><?php echo $form['ds_tags']->renderLabel() ?></th>
		        <td>
		          <?php echo $form['ds_tags'] ?>
		          <?php echo form_error('item[ds_tags]'); ?>
		        </td>
		      </tr>
		    </tbody>
		  </table>
		</div>
	
	<?php if ($form->getObject()->isNew()): ?>
    <div id="tab_midia">
        <?php include_component('midia', 'new', array('form' => $form, 'hasmany' => true, 'name' => 'item')); ?>
    </div>
    <?php endif; ?>
</div>
</form>

<?php
	comandos_form(
		link_to(
			':: Listar ::',
			'extra/list',
			array('class' => 'botao')
		),
		button_to_function(
			':: Salvar ::',
			"$('#form_extra').submit()",
			array('class' => 'botao')
		)
	);
?>
<script type="text/javascript">
$(function()
{
	System.setdata.tab();
});
</script>